home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 037a / sbts.zip / SBTS.PAS < prev   
Pascal/Delphi Source File  |  1992-01-01  |  5KB  |  174 lines

  1. { SBTS.PAS -- Sound Blaster Text To Speech Interface for Turbo Pascal 6.0 }
  2.  
  3. Unit SBTS;
  4.  
  5. Interface
  6.  
  7. {$IFNDEF VER60 }
  8.    ** Needs Version 6.0 of Turbo Pascal to compile **
  9. {$ENDIF }
  10.  
  11. {                                  SBTS.PAS
  12.  
  13.       This unit provides an interface to the SBTALKER (TM) Text-to-Speech
  14.       driver.
  15.  
  16.       USAGE NOTES:
  17.        1.  Make sure you have made SBTALKER resident, prior to running your
  18.            application.  Call from the DOS command line:
  19.               SBTALKER /DBLASTER
  20.  
  21.            SBTALKER.EXE and BLASTER.DRV are found on the diskettes that
  22.            came with the Sound Blaster.
  23.        2.  Due to the fact that this unit relies on the built-in assembler,
  24.            you'll need Turbo Pascal, version 6.0 or later to recompile.
  25.        3.  IMPORTANT:  Don't attempt to run an application within the
  26.            Turbo Pascal Integrated Development Environment.  Do not launch
  27.            it inside a software-debugger either!  It'll HANG your system.
  28.            RUN it from the DOS command line.
  29.  
  30.        Written by Wilbert van Leijen, Amsterdam 1991.
  31.        Released with source code and all to the Public Domain on an
  32.        AS-IS basis.  The author assumes NO liability; you use this at your
  33.        risk.
  34.  
  35. }
  36. Type
  37.   SpeechType   = Record                { SBTALKER configuration record }
  38.                    talk,
  39.                    phoneme     : String;
  40.                    gender,
  41.                    tone,
  42.                    volume,
  43.                    pitch,
  44.                    speed       : Integer;
  45.                  end;
  46. Const
  47.   TalkerReady  : Boolean = False;      { Flag indicating SBTALKER status }
  48.  
  49. Var
  50.   TalkPtr      : Pointer;              { Pointer to the resident driver }
  51.   SpeechRec    : ^SpeechType;          { Pointer to the configuration record }
  52.  
  53. Procedure Say(talk : String);
  54. Procedure Settings(gender, tone, volume, pitch, speed : Integer); Function 
  55. UnloadDriver : Boolean;
  56.  
  57. Implementation
  58.  
  59. {$R-,S- }
  60.  
  61. { Talk to me }
  62.  
  63. Procedure Say(talk : String); Assembler;
  64.  
  65. ASM
  66.         CMP    [TalkerReady], False
  67.         JE     @1
  68.         LES    DI, [SpeechRec]
  69.         PUSH   DS
  70.         LDS    SI, talk
  71.         CLD
  72.         LODSB
  73.         STOSB
  74.         XOR    CH, CH
  75.         MOV    CL, AL
  76.         REP    MOVSB
  77.         POP    DS
  78.         MOV    AL, 7
  79.         CALL   [TalkPtr]
  80. @1:
  81. end;  { Say }
  82.  
  83.  
  84. { Alter the settings of the SBTALKER driver }
  85.  
  86. Procedure Settings(gender, tone, volume, pitch, speed : Integer); Assembler;
  87.  
  88. ASM
  89.         CMP    [TalkerReady], False
  90.         JE     @1
  91.         LES    DI, [SpeechRec]
  92.         CLD
  93.         ADD    DI, SpeechType.gender
  94.         MOV    AX, gender
  95.         STOSW
  96.         MOV    AX, tone
  97.         STOSW
  98.         MOV    AX, volume
  99.         STOSW
  100.         MOV    AX, pitch
  101.         STOSW
  102.         MOV    AX, speed
  103.         STOSW
  104.         MOV    AL, 2
  105.         CALL   [TalkPtr]
  106. @1:
  107. end;  { Settings }
  108.  
  109. { Unload the SBTALKER driver.  Returns True is successful }
  110.  
  111. Function UnloadDriver : Boolean; Assembler;
  112.  
  113. ASM
  114.         MOV    AX, False
  115.         CMP    [TalkerReady], False
  116.         JE     @1
  117.         MOV    AX, 0FBFFh
  118.         INT    2Fh
  119. @1:
  120. end;  { UnloadDriver }
  121.  
  122. Begin  { SBTS }
  123. ASM
  124.  
  125.   { Get the vector to multiplex interrupt 2Fh.  Assume it belongs to SBTALKER }
  126.  
  127.         MOV    AX, 352Fh
  128.         INT    21h
  129.         MOV    AX, ES
  130.         OR     AX, AX
  131.         JZ     @1
  132.  
  133.   { Pass the magic number to the handler }
  134.  
  135.         MOV    AX, 0FBFBh
  136.         INT    2Fh
  137.  
  138.   { Driver responds if the return code is non zero }
  139.  
  140.         OR     AX, AX
  141.         JNE    @1
  142.  
  143.   { Retrieve the pointers to the SBTALKER driver and its configuration record }
  144.  
  145.         MOV    AX, ES:[BX+4]
  146.         MOV    DX, ES:[BX+6]
  147.         MOV    Word Ptr [TalkPtr], AX
  148.         MOV    Word Ptr [TalkPtr+2], DX
  149.         ADD    BX, 20h
  150.         MOV    Word Ptr [SpeechRec], BX
  151.         MOV    Word Ptr [SpeechRec+2], DX
  152.  
  153.   { Put the default values for gender, tone etc. into this record }
  154.  
  155.         LES    DI, [SpeechRec]
  156.         ADD    DI, SpeechType.gender
  157.         CLD
  158.         SUB    AX, AX
  159.         STOSW                          { gender = male }
  160.         STOSW                          { tone   = bass }
  161.         MOV    AX, 5
  162.         STOSW                          { volume = 5 }
  163.         STOSW                          { pitch  = 5 }
  164.         STOSW                          { speed  = 5 }
  165.         MOV    AL, 2
  166.         CALL   [TalkPtr]
  167.         MOV    [TalkerReady], True
  168. @1:
  169. end;
  170. end.  { SBTS }
  171.  
  172. Sample call:  Say('hello world!');
  173.  
  174.